execute store result score @s advm_power run data get entity @s Inventory[-1].tag.power
execute store result score @s advm_power_cost run data get entity @s SelectedItem.tag.power_cost
execute if data entity @s SelectedItem.tag.electricalAttribute.hyperload run scoreboard players operation @s advm_power_cost += @s advm_power_cost
execute if data entity @s SelectedItem.tag.electricalAttribute.efficient_use run scoreboard players operation @s advm_power_cost /= @s advm_efficient_use_devide
execute if score @s advm_power matches 1.. run scoreboard players operation @s advm_power -= @s advm_power_cost
execute if score @s advm_power matches ..0 run scoreboard players set @s advm_power 0
execute store result storage advm:temp power int 1 run scoreboard players get @s advm_power
item modify entity @s weapon.offhand advm:set_power
execute as @s[nbt={Inventory:[{Slot:-106b,tag:{id:"advm:battery",chargeable:0b}}]}] if score @s advm_power matches ..0 run loot replace entity @s weapon.offhand loot advm:battery_used_up
execute as @s[nbt={Inventory:[{Slot:-106b,tag:{id:"advm:battery",chargeable:1b}}]}] if score @s advm_power matches ..0 run item modify entity @s weapon.offhand advm:set_used
